﻿package mortal.game.net.command.copy.petBreakCopy
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import mortal.component.gconst.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.copy.petBreak.*;
    import mortal.game.view.mainUI.shortcutbar.exSkill.*;
    import mortal.mvc.core.*;

    public class PetBreakCopyCommand extends BroadCastCall
    {

        public function PetBreakCopyCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_2:SPetBreakInfo = null;
            var _loc_3:SPetBreakCopyResult = null;
            var _loc_4:SPetBreakCopyTime = null;
            var _loc_5:SSkillMsg = null;
            super.call(param1);
            switch(param1.messageHead.command)
            {
                case EGateCommand._ECmdGatePetBreakInfo:
                {
                    _loc_2 = param1.messageBase as SPetBreakInfo;
                    _cache.copy.petBreakCopy.petBreakInfo = _loc_2;
                    NetDispatcher.dispatchCmd(ServerCommand.PetBreakCopyInfoUpdate, null);
                    break;
                }
                case EPublicCommand._ECmdPublicEndPetBreakCopy:
                {
                    _loc_3 = param1.messageBase as SPetBreakCopyResult;
                    NetDispatcher.dispatchCmd(ServerCommand.PetBreakCopyEndInfo, {result:_loc_3, isSweep:false});
                    break;
                }
                case EPublicCommand._ECmdPublicPetBreakTime:
                {
                    _loc_4 = param1.messageBase as SPetBreakCopyTime;
                    NetDispatcher.dispatchCmd(ServerCommand.PetBreakCopyTime, _loc_4);
                    break;
                }
                case EPublicCommand._ECmdPublicPetBreakSkill:
                {
                    ExSkillShortcutBar.eventMoveIn = true;
                    ExSkillShortcutBar.itemIsDropable = true;
                    ExSkillShortcutBar.beidongSkillFilter = true;
                    NetDispatcher.dispatchCmd(ServerCommand.SkillExListUpdate, GameConst.PetBreakCopyMaxSkill);
                    _loc_5 = param1.messageBase as SSkillMsg;
                    _loc_5.skills.sort(this.sortFun);
                    _cache.skill.initExSkillList(PetBreakCopyUtil.baseSkill.concat(_loc_5.skills));
                    NetDispatcher.dispatchCmd(ServerCommand.SkillExListCdUpdate, null);
                    NetDispatcher.dispatchCmd(ServerCommand.ExSkillShortcutBarDataUpdate, null);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function sortFun(param1:SSkill, param2:SSkill) : int
        {
            var _loc_5:TSkill = null;
            var _loc_6:TSkill = null;
            var _loc_3:* = int(String(param1.skillId).slice(0, 2));
            var _loc_4:* = int(String(param2.skillId).slice(0, 2));
            if (_loc_3 < _loc_4)
            {
                return -1;
            }
            _loc_5 = SkillConfig.instance.getInfoById(param1.skillId);
            _loc_6 = SkillConfig.instance.getInfoById(param2.skillId);
            if (_loc_5.triggerType < _loc_6.triggerType)
            {
                return -1;
            }
            if (_loc_5.triggerType > _loc_6.triggerType)
            {
                return 1;
            }
            return 0;
        }// end function

    }
}
